import http from '@/api/http'
import type {
    APIResult,
    APIPaging,
    PaginationParams,
    InventoryItemDTO,
    InventoryMovementDTO,
    InventoryQueryParams
} from '@/api/types'

export const inventoryAPI = {
    // 获取库存列表
    getInventoryList: (
        params: PaginationParams & InventoryQueryParams
    ): Promise<APIResult<APIPaging<InventoryItemDTO>>> => {
        return http.get('/inventory/list', { params })
    },

    // 获取库存流水记录
    getMovementRecords: (
        params: PaginationParams & { materialCode?: string }
    ): Promise<APIResult<APIPaging<InventoryMovementDTO>>> => {
        return http.get('/inventory/movements', { params })
    },

    // 库存调整
    adjustStock: (data: {
        materialCode: string
        warehouse: string
        adjustmentQuantity: number
        reason: string
    }): Promise<APIResult<void>> => {
        return http.post('/inventory/adjust', data)
    },

    // 库存盘点
    createInventoryCheck: (data: {
        warehouse: string
        checkTime: string
    }): Promise<APIResult<string>> => {
        return http.post('/inventory/check', data)
    }
}